package hhpoll.dao.hibernate;

import hhpoll.dao.DAOFactory;
import hhpoll.dao.PollDAO;
import hhpoll.dao.PollItemDAO;
import hhpoll.dao.PollParticipantDAO;
import hhpoll.dao.UserDAO;
import hhpoll.dao.UserRegistrationDAO;

import org.hibernate.SessionFactory;

public class HibernateDAOFactory implements DAOFactory {

    private SessionFactory sessionFactory;

    public HibernateDAOFactory (SessionFactory sessionFactory) {
        System.out.println("Creating HibernateDAOFactory");
        this.sessionFactory = sessionFactory;
    }

    public PollDAO createPollDAO () {
        return new HibernatePollDAO(this.sessionFactory);
    }

    public PollItemDAO createPollItemDAO () {
        return new HibernatePollItemDAO(this.sessionFactory);
    }

    public PollParticipantDAO createPollParticipantDAO () {
        return new HibernatePollParticipantDAO(this.sessionFactory);
    }

    public UserDAO createUserDAO () {
        return new HibernateUserDAO(this.sessionFactory);
    }
    
    public UserRegistrationDAO createUserRegistrationDAO () {
        return new HibernateUserRegistrationDAO(this.sessionFactory);
    }
}
